package com.zsrt.java.ex.facotry;

public class ObjectFacotry {
	
	public static Person createObj(String type){
		
		Person p=null;
		if("学生".equals(type)){
			System.out.println("创建一个学生");
			p=new Student();
		}else if("工人".equals(type)){
			System.out.println("创建一个工人");
			p=new Worker();
		}
		return p;
	}
	
	public static Person createStudent(){
		System.out.println("创建一个学生2");
		return new Student();
	}
	
	public static Person createWorker(){
		System.out.println("创建一个工人2");
		return new Worker();
	}

}
